IK Set Color To Alpha


IK Set Color To Alpha Image Number, Color
IK Set Color To Alpha Image Number, Color, Mode

Description

This command will compare the red, green and blue components of Color to each pixel in the image. If it matches, the alpha value of that pixel will be changed to zero. If it doesn't, then the pixel will remain unchanged (including the alpha channel).

In the second version of the command, you can choose the algorithm used. Using a value of 0 (COLORTOALPHA_HARD) for Mode will produce the same result as the first version. When using a value of 1 (COLORTOALPHA_SOFT), then the used algorithm is quite different. In that case, Image Kit will try to produce an image that gives the original image when pasted on an opaque image with color Color, as shown in blue in the following figure.

Example of soft color to alpha
This command does not work on render targets, but the same effect can be achieved using the effect commands of Image Kit and a pixel shader.

Parameters

Image NumberIntegerThe ID of the image.
ColorDWORDThe color to be made transparent.


Index